import { graphic } from "echarts/core";

export const dashOpt1 = {
  xAxis: {
    type: "category",
    boundaryGap: false,
    data: [],
  },
  yAxis: {
    type: "value",
  },
  grid: {
    top: "2%",
    left: "2%",
    right: "5%",
    bottom: "2%",
    containLabel: true,
  },
  color: ["#009688", "#f44336"],
  series: [
    {
      type: "line",
      areaStyle: {
        color: new graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: "rgba(0, 150, 136,0.8)",
          },
          {
            offset: 1,
            color: "rgba(0, 150, 136,0.2)",
          },
        ]),
      },
      smooth: true,
      data: [120, 132, 301, 134, 90, 230, 210],
    },
    {
      type: "line",
      smooth: true,
      data: [220, 122, 191, 234, 190, 130, 310],
    },
  ],
};

// 处理实时更新日期的逻辑============================================================start
const currentDate = new Date();
const currentYear = currentDate.getFullYear(); // 获取当前年份
const currentMonth = currentDate.getMonth() + 1; // 获取当前月份，注意月份是从0开始计数，所以要加1
const currentDay = currentDate.getDate(); // 获取当前日期

const newData = [];
for (let i = 0; i < 7; i++) {
  const date = new Date(currentYear, currentMonth - 1, currentDay + i); // 构造日期对象
  const formattedDate = `${date.getFullYear()}/${
    date.getMonth() + 1
  }/${date.getDate()}`; // 格式化日期
  newData.push(formattedDate);
}

// 更新 dashOpt1 对象的 data 属性
dashOpt1.xAxis.data = newData;
// console.log("????", dashOpt1.xAxis.data);
// console.log("!!!!!!", newData);

// 处理实时更新日期的逻辑============================================================end

export const dashOpt2 = {
  legend: {
    bottom: "1%",
    left: "center",
  },
  // grid: {
  //   top: "1%",
  //   left: "50%",
  //   right: "50%",
  //   bottom: "1%",
  //   containLabel: true,
  // },
  color: ["#3f51b5", "#009688", "#f44336", "#00bcd4", "#1ABC9C"],
  series: [
    {
      type: "pie",
      radius: ["30%", "60%"],
      avoidLabelOverlap: false,
      itemStyle: {
        borderRadius: 10,
        borderColor: "#fff",
        borderWidth: 2,
      },
      data: [
        { value: 1048, name: "猫类" },
        { value: 735, name: "中华田园犬" },
        { value: 580, name: "鸟类" },
        { value: 484, name: "兔子" },
        { value: 300, name: "哈士奇犬类" },
      ],
    },
  ],
};

export const mapOptions = {
  tooltip: {
    trigger: "item",
  },
  geo: {
    map: "china",
    roam: false,
    emphasis: {
      label: {
        show: false,
      },
    },
  },
  visualMap: {
    show: false,
    min: 0,
    max: 100,
    realtime: false,
    calculable: false,
    inRange: {
      color: ["#d2e0f5", "#71A9FF"],
    },
  },
  series: [
    {
      geoIndex: 0,
      name: "地域分布",
      type: "map",
      coordinateSystem: "geo",
      map: "china",
      data: [
        { name: "北京", value: 100 },
        { name: "上海", value: 100 },
        { name: "广东", value: 100 },
        { name: "浙江", value: 90 },
        { name: "江西", value: 80 },
        { name: "山东", value: 70 },
        { name: "广西", value: 60 },
        { name: "河南", value: 50 },
        { name: "河南", value: 40 },
        { name: "青海", value: 70 },
        { name: "河南", value: 30 },
        { name: "黑龙江", value: 20 },
        { name: "新疆", value: 20 },
        { name: "云南", value: 20 },
        { name: "甘肃", value: 20 },
      ],
    },
  ],
};
